﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace _0517
{
    public partial class frmLogin : Form
    {
        int i = 0;
        public frmLogin()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmReg reg = new frmReg();
            reg.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string userid, pwd;
            string strSql = "";
            DataSet ds;
            if (textBox1.Text.Trim() != "" && textBox2.Text.Trim() != "")
            {
                userid = textBox1.Text.Trim();
                pwd = textBox2.Text.Trim();
                strSql = "select * from Usery where ID='" + userid + "' and Pwd='" + pwd + "'";
                _0517病例系统.DataAccess data = new _0517病例系统.DataAccess();
                data.dataCon();
                ds = data.getDataset(strSql);
                if (ds.Tables[0].Rows.Count == 1)
                {
                    frmMain main = new frmMain();
                    main.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误！", "登录失败");
                    textBox1.Text = "";
                    textBox2.Text = "";
                    i++;
                    if (i == 3)
                        Application.Exit();
                }
            }
            
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
